FROM ubuntu:20.04

MAINTAINER by weni09

ENV DEBIAN_FRONTEND=noninteractive
ARG pip_url=https://mirrors.aliyun.com/pypi/simple/
ARG pip_host=mirrors.aliyun.com
# 安装git、python、nginx、supervisor等，并清理缓存
ADD sources.list /etc/apt/
RUN apt clean && apt update
RUN mkdir /app
RUN apt install  -y \
        git \
        python3 \
        python3-dev \
        python3-setuptools \
        python3-pip \
        nginx \
        supervisor \
        libmysqlclient-dev && \
        pip3 install --upgrade pip setuptools -i ${pip_url} --trusted-host ${pip_host} && \
        rm -rf /var/lib/apt/lists/*


RUN apt install -y tzdata
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone

RUN pip3 install -i ${pip_url} --trusted-host ${pip_host} uwsgi

# 环境变量
ENV IZONE_MYSQL_NAME izone

# nginx、supervisor配置
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY nginx-app.conf /etc/nginx/sites-available/default
COPY supervisor-app.conf /etc/supervisor/conf.d/

# 安装项目所需python第三方库
COPY requirements.txt /app/izone/
RUN pip install -i ${pip_url} -r /app/izone/requirements.txt

#uwsgi 日志文件
RUN mkdir -p /var/log/uwsgi/ && touch /var/log/uwsgi/app_izone.log && chmod 755 -R /var/log/uwsgi/
# uwsgi.ini 及 uwsgi_params
COPY . /app/

EXPOSE 9093
CMD ["supervisord", "-n"]
